package code.whmmm.util.simple.serialize;

import com.alibaba.fastjson.JSON;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import code.whmmm.util.simple.serialize.inter.SerializeUtil;

/**
 * <p><b>
 * fastJson 序列化 工具类 需要实例化
 * </b></p>
 * <br/>
 *
 * @author Zero
 * @date 9/11/2019 8:59 PM
 */
public class JsonSerializeUtil implements SerializeUtil {


    private static Logger log = LoggerFactory.getLogger(JsonSerializeUtil.class);

    @Override
    public byte[] serialize(Object object) {
        //, SerializerFeature.WriteMapNullValue 包含空字符
        return JSON.toJSONBytes(object);
    }

    @Override
    public <T> T unSerialize(byte[] bytes, Class<T> tClass) {
        return JSON.parseObject(bytes, tClass);
    }


}
